package com.an.collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@SuppressWarnings({"all"})
public class HomeWork_1 {
    public static void main(String[] args) {
        Collection collection=new ArrayList();
        collection.add(new Dog("大黄",5));
        collection.add(new Dog("岸田文雄",9));
        collection.add(new Dog("东条英机",7));
        collection.add(new Dog("安倍晋三",3));
        Iterator iterator=collection.iterator();
        for (Object o :collection) {
            System.out.println(o);
        }
        while(iterator.hasNext()){
            System.out.println(iterator.next());
        }
        iterator=collection.iterator();
        while(iterator.hasNext()){
            System.out.println(iterator.next());
        }


    }
}
class Dog{
    private String name;
    private int age;

    public Dog(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Dog{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}